package com.supinfo.sun.sungamers.person;

import com.supinfo.sun.sungamers.exceptions.NoGameException;
import com.supinfo.sun.sungamers.games.FinderGame;

/**
 * @author Liu, Bing(Locke)
 * @since 2011-04-05
 * @version 0.3
 */
public class Gamer extends Person{
	
	private FinderGame preferredGame;
	
	public Gamer() {}
	
	public void playGame(FinderGame...finderGames) throws NoGameException {
		if(finderGames.length > 0) {
			for(FinderGame finderGame : finderGames) {
				finderGame.initGame();
				finderGame.play();
			}
		}
		else {
			if(preferredGame != null) {
				preferredGame.initGame();
				preferredGame.play();
			}
			else
				throw new NoGameException("No preferred game");
		}
	}

	public FinderGame getPreferredGame() {
		return preferredGame;
	}

	public void setPreferredGame(FinderGame preferredGame) {
		this.preferredGame = preferredGame;
	}
}
